package me.zhengjie.sqlservice.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import me.zhengjie.mapper.LiftMapper;
import me.zhengjie.pojo.entity.Lift;
import me.zhengjie.sqlservice.LiftSqlService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class LiftSqlServiceImpl extends ServiceImpl<LiftMapper, Lift> implements LiftSqlService {
    private final LiftMapper liftMapper;

    @Override
    public Lift selectLiftCode(String liftCode) {
        LambdaQueryWrapper<Lift> liftLambdaQueryWrapper = new LambdaQueryWrapper<>();
        liftLambdaQueryWrapper.eq(Lift::getLiftCode,liftCode);
        return liftMapper.selectOne(liftLambdaQueryWrapper);
    }

    @Override
    public List<Lift> selectAll() {
        return liftMapper.selectList(null);
    }

    @Override
    public Lift selectIpPort(String ip, int port) {
        LambdaQueryWrapper<Lift> liftLambdaQueryWrapper = new LambdaQueryWrapper<>();
        liftLambdaQueryWrapper.eq(Lift::getIp,ip)
                .eq(Lift::getPort,port);
        return liftMapper.selectOne(liftLambdaQueryWrapper);
    }
}
